package com.hu.zhcc.shiro.service.dingming;

import com.hu.zhcc.common.entity.Page;
import com.hu.zhcc.common.entity.PageRequest;
import com.hu.zhcc.shiro.dao.dingming.TCheckitemMapper;
import com.hu.zhcc.shiro.entity.dingming.TCheckitem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TCheckItemServiceImpl implements TCheckItemService{
    @Autowired
    private TCheckitemMapper tCheckitemMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return tCheckitemMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(TCheckitem record) {
        return tCheckitemMapper.insert(record);
    }

    @Override
    public int insertSelective(TCheckitem record) {
        return tCheckitemMapper.insertSelective(record);
    }

    @Override
    public TCheckitem selectByPrimaryKey(Integer id) {
        return tCheckitemMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(TCheckitem record) {
        return updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(TCheckitem record) {
        return tCheckitemMapper.updateByPrimaryKey(record);
    }

    @Override
    public Page<TCheckitem> listCheckItem(Map<String, Object> parameters, int offset, int limit) {
        int total = tCheckitemMapper.countCheckItem(parameters);
        List<TCheckitem> checkItemList = null;
        if (total > 0) {
            PageRequest pageRequest = new PageRequest(offset, limit, parameters);
            System.out.println("pageRequest"+pageRequest);
            checkItemList = tCheckitemMapper.listCheckItem(pageRequest);
        }
        return new Page<TCheckitem>(total, checkItemList);
    }
}
